package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.RecommendResponse;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: ProductRecommendController
 * @Description:
 * @Author: 你猜
 * @Date: 2022/6/17 20:05
 */

@RestController
public class ProductRecommendController {

    @Autowired
    IProductService productService;

    @GetMapping("/shopping/recommend")
    public ResponseData getProductRecommend() {

        // http://124.71.209.81/shopping/recommend
        RecommendResponse response = productService.getRecommendGoods();
        if (ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())) {
            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}